<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			window.onload = function()
			{
				let sel = document.querySelector('select');
				let button = document.querySelector('button');
				let fn = function() {
					alert('hello');
					}
				sel.onchange = function() {
					if (sel.value == 1) {
						button.addEventListener('click', fn)
						}
					if (sel.value == 2) {
						button.removeEventListener('click', fn);
						}
					}
			}
		</script>
	</head>
	<body>
		<button>按钮</button>
		<select>
			<option value="0">请选择事件</option>
			<option value="1">加入事件</option>
			<option value="2">取消事件</option>
		</select>
	</body>
</html>